package com.unisound.tracelog.server.ui.converter;

import com.unisound.tracelog.server.model.entity.TraceLog;
import com.unisound.tracelog.server.ui.model.response.TraceLogResponse;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class TraceLogToResponseConverter implements Converter<TraceLog, TraceLogResponse> {
    @Override
    public TraceLogResponse convert(TraceLog source) {
        return TraceLogResponse.builder()
                .traceId(source.getTraceId())
                .spanId(source.getSpanId())
                .parentSpanId(source.getParentSpanId())
                .name(source.getName())
                .serviceName(source.getServiceName())
                .type(source.getType())
                .startTime(source.getStartTime())
                .endTime(source.getEndTime())
                .elapsedTime(source.getElapsedTime())
                .resultFlag(source.getResultFlag())
                .input(source.getInput())
                .output(source.getOutput())
                .build();
    }

}
